home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.ivb.jface.jfacex;
-
- import com.ibm.ivb.jface.plus.OpenAction;
- import com.ibm.ivf.ui.browser.interfaces.IDomainModel;
- import com.ibm.ivf.ui.browser.interfaces.IElement;
- import com.ibm.ivf.ui.browser.interfaces.IIndexedProperty;
- import com.ibm.ivf.ui.browser.interfaces.IProperty;
- import com.ibm.ivf.ui.browser.interfaces.ISimpleProperty;
- import com.ibm.ivf.ui.browser.interfaces.SetPropertyVetoException;
- import com.ibm.ivf.ui.browser.model.ElementSetProperty;
- import com.ibm.ivf.ui.browser.model.IBasicProperties;
- import com.ibm.ivf.ui.browser.model.SimpleProperty;
- import com.ibm.xml.parser.Child;
- import com.ibm.xml.parser.Parent;
- import com.ibm.xml.parser.TXElement;
- import java.io.Serializable;
- import java.util.Hashtable;
- import javax.swing.ImageIcon;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
-
- public class XMLModelElement extends TXElement implements IElement, IBasicProperties, Serializable {
- private static final String kHABIBMCopyright = "(c) Copyright IBM Corporation 1998";
- private IDomainModel model;
- private boolean deleted = false;
- protected Hashtable caches;
- private static boolean loadTime;
-
- public XMLModelElement(IDomainModel var1, String var2, String var3) {
- super(var2);
- this.model = var1;
- ((TXElement)this).setAttribute("name", var3);
- }
-
- public void addChildElement(String var1, XMLModelElement var2) {
- ElementSetProperty var3 = (ElementSetProperty)this.getIndexedProperty(var1, var2.getType());
- var3.add(var2);
- ((Parent)this).appendChild(var2);
- this.getDomain().fireDomainChanged(this, var1, var2);
- }
-
- public IDomainModel getDomain() {
- return this.model;
- }
-
- public ImageIcon getIcon() {
- IProperty var1 = this.getProperty("icon");
- if (var1 != null) {
- ISimpleProperty var2 = var1.toSimpleProperty();
- if (var2 != null) {
- return var2.toIcon();
- }
- }
-
- return null;
- }
-
- protected IIndexedProperty getIndexedProperty(String var1, String var2) {
- if (this.caches == null) {
- this.caches = new Hashtable();
- }
-
- ElementSetProperty var3 = (ElementSetProperty)this.caches.get(var1);
- if (var3 == null) {
- var3 = new ElementSetProperty();
- this.caches.put(var1, var3);
- NodeList var4 = ((Parent)this).getChildNodes();
-
- for(int var5 = 0; var5 < var4.getLength(); ++var5) {
- Node var6 = var4.item(var5);
- if (var6 instanceof XMLModelElement) {
- XMLModelElement var7 = (XMLModelElement)var4.item(var5);
- if (var2 == null || var2.equals(var7.getType())) {
- var3.add(var7);
- }
- }
- }
- }
-
- return var3;
- }
-
- public String getName() {
- if (loadTime) {
- return super.getName();
- } else {
- IProperty var1 = this.getProperty("name");
- return var1 == null ? null : var1.toString();
- }
- }
-
- public XMLModelElement getParent() {
- Node var1 = ((Child)this).getParentNode();
- return var1 instanceof XMLModelElement ? (XMLModelElement)var1 : null;
- }
-
- public IProperty getProperty(String var1) {
- if ("icon".equals(var1)) {
- IDomainModel var2 = this.getDomain();
- if (var2 != null) {
- ImageIcon var3 = var2.getIcon(this.getType());
- if (var3 != null) {
- return new SimpleProperty(var3);
- }
- }
- }
-
- if ("name".equals(var1)) {
- return new SimpleProperty(((TXElement)this).getAttribute("name"));
- } else if ("type".equals(var1)) {
- return new SimpleProperty(((TXElement)this).getTagName());
- } else {
- return "JFacePlusOpenAction".equals(var1) ? new SimpleProperty(new OpenAction(this)) : null;
- }
- }
-
- public String getType() {
- IProperty var1 = this.getProperty("type");
- return var1 == null ? null : var1.toString();
- }
-
- public boolean hasProperty(String var1) {
- return this.getProperty(var1) != null;
- }
-
- public boolean isDeleted() {
- return this.deleted;
- }
-
- public void removeChildElement(String var1, XMLModelElement var2) {
- ((Parent)this).removeChild(var2);
- ElementSetProperty var3 = (ElementSetProperty)this.getIndexedProperty(var1, var2.getType());
- var3.remove(var2);
- var2.setDeleted(true);
- this.getDomain().fireDomainChanged(this, var1, var2);
- }
-
- public void setChildrenDeleted(boolean var1) {
- NodeList var2 = ((Parent)this).getChildNodes();
-
- for(int var3 = 0; var3 < var2.getLength(); ++var3) {
- Node var4 = var2.item(var3);
- if (var4 instanceof XMLModelElement) {
- XMLModelElement var5 = (XMLModelElement)var2.item(var3);
- var5.setDeleted(true);
- var5.setChildrenDeleted(true);
- }
- }
-
- }
-
- public void setDeleted(boolean var1) {
- this.deleted = var1;
- }
-
- public static void setLoadTime(boolean var0) {
- loadTime = var0;
- }
-
- public void setName(String var1) {
- ((TXElement)this).setAttribute("name", var1);
- }
-
- public void setProperty(String var1, IProperty var2) throws SetPropertyVetoException {
- if ("name".equals(var1)) {
- ((TXElement)this).setAttribute("name", var2.toString());
- this.getDomain().fireDomainChanged(this, var1);
- } else if ("type".equals(var1)) {
- ((TXElement)this).setTagName(var2.toString());
- this.getDomain().fireDomainChanged(this, var1);
- }
- }
-
- public final void setType(String var1) {
- try {
- this.setProperty("type", new SimpleProperty(var1));
- } catch (SetPropertyVetoException var2) {
- }
- }
-
- public String toString() {
- String var1 = this.getName();
- return var1 == null ? "???" : var1;
- }
- }
-